# -*- encoding=utf8 -*-
"""
RedFlag-TC000047   左右滑动页面
左右滑动切换视频与拍照场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)


from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("---------------------------------左右滑动切换视频与拍照场景-------------------------------------")
"""
进入相机拍摄
进行截屏
点击拍照
进行截屏
滑动切换到视频
断言
滑动切换到照片
断言
"""

shooter.enter_photograph()
sleep(1.0)
png1 = shooter.capture_screenshot(file_name="TC000047A.png")
shooter.click_element(shoot_page_pictures)
png2 = shooter.capture_screenshot(file_name="TC000047B.png")
shooter.swipe_screen((0.1,0.5), (0.7,0.5), duration=0.3)
sleep(1.0)
shooter.assert_image_exists(png1,"断言失败，图片与预期图片不符合",threshold = 0.90)
shooter.swipe_screen((0.7,0.5), (0.1,0.5), duration=0.3)
sleep(1.0)
shooter.assert_image_exists(png2,"断言失败，图片与预期图片不符合",threshold = 0.90)

# 关闭应用
stop_app(UGC_package_name)